package com.example.shopping.member.mapper;
import com.example.shopping.member.entity.member;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MemberMapper {
    //查询
    @Select("select * from member")
    List<member> getmemberlist();

    //按照id查询会员
    @Select("select * from member where userid=#{userid}")
    List<member> getmember_ID_list(@Param("userid")int userid);

    //修改用户金额
    @Update("update member set cardprice=cardprice+#{cardprice} where id=#{id}")
    int updmemberPrice(@Param("cardprice")int cardprice,@Param("id")int id);


    @Delete("delete from member where id=#{id}")
    int delememberlist(@Param("id") int id);
    //查询id
    @Select("select * from member where id=#{id}")
    List<member> getmemberid(@Param("id") int id);
    //修改
    @Update("update member set state=#{state},vaildtime=#{vaildtime} where id=#{id}")
    int updmember(@Param("state")int state,@Param("vaildtime") String vaildtime, @Param("id") int id);
    //增加
    @Insert("INSERT INTO member(userid,carddengji,cardname,cardprice,state,vaildtime) VALUES(#{userid},#{carddengji},#{cardname},#{cardprice},#{state},#{vaildtime})")
    int addmember(@Param("userid") int userid, @Param("carddengji") int carddengji, @Param("cardprice") int cardprice,@Param("cardname") String cardname,@Param("state") int state,@Param("vaildtime")  String vaildtime);
}
